'use strict';

const Controller = require('egg').Controller;

class PdfController extends Controller {

	// 根据url生成对应的pdf
	async create(){
		const ctx = this.ctx;
		const rule = {
			url:'string',
			size:'string?',
			marginLeft:'string?',
			marginTop:'string?',
			marginBottom:'string?',
			marginRight:'string?'
		}
		const errors = this.app.validator.validate(rule,ctx.request.body);
		if(errors){
			ctx.body = ctx.helper.fail('参数不对',errors);
			return;
		}
        const sendDate = ctx.request.body;
        const res = await ctx.service.pdf.create(sendDate);
		ctx.body = res;
	}
        
}

module.exports = PdfController;